package cn.jiyun.controller;

import cn.jiyun.config.UserProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
public class ConfigController {
/**
 * 将读取的配置信息返回给前端
 */

    @Value("${user.username}")
    private  String username;
    @Value("${user.age}")
    private  Integer age;
    @Value("${user.phone}")
    private  String phone;
/*    @Value("${user.hobby}")
    private  String [] hobby;*/


@RequestMapping("config")
    public Map<String,Object>config() {
    Map<String, Object> map = new HashMap<>();
    map.put("username",username);
    map.put("age",age);
    map.put("phone",phone);
   /* map.put("hobby",hobby);*/
    return map;
}

@Autowired
private UserProperties userProperties;
@RequestMapping("config2")
    public UserProperties config2() {
    return userProperties;
}

}